# Ruta de destino accesible para todos los usuarios
$xmlPath = "C:\AJUSTE EDGE\sites.xml"

# Asegurar que el directorio de destino exista
if (-not (Test-Path "C:\AJUSTE EDGE")) {
    New-Item -ItemType Directory -Path "C:\AJUSTE EDGE" -Force | Out-Null
}

# Copiar sites.xml desde la carpeta actual (archivos_soporte) a la ruta de destino
$sourceXml = Join-Path $PSScriptRoot "sites.xml"
if (Test-Path $sourceXml) {
    Copy-Item $sourceXml $xmlPath -Force
} else {
    Copy-Item ".\sites.xml" $xmlPath -Force
}

# Ruta del registro para IE Mode en Edge (todos los usuarios)
$regRoot = "HKLM:\Software\Policies"
$regPath = "$regRoot\Microsoft\Edge"

# Crear las claves de registro si no existen
if (-not (Test-Path $regRoot)) {
    New-Item -Path $regRoot -Force | Out-Null
}
if (-not (Test-Path "$regRoot\Microsoft")) {
    New-Item -Path "$regRoot\Microsoft" -Force | Out-Null
}
if (-not (Test-Path $regPath)) {
    New-Item -Path $regPath -Force | Out-Null
}

# Habilitar integración con IE Mode
Set-ItemProperty -Path $regPath -Name "InternetExplorerIntegrationLevel" -Value 1

# Registrar la lista de compatibilidad para todos los usuarios
Set-ItemProperty -Path $regPath -Name "InternetExplorerIntegrationSiteList" -Value $xmlPath

Write-Host "Archivo sites.xml registrado en HKLM. Reinicia Edge para aplicar IE Mode a todos los usuarios."
